package com.chengqs.service.Impl;

import com.chengqs.mapper.MovieMapper;
import com.chengqs.pojo.DTO.MoviePageQueryDTO;
import com.chengqs.pojo.entity.Movie;
import com.chengqs.service.MovieService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MovieServiceImpl implements MovieService {
    @Autowired
    private MovieMapper movieMapper;
    @Override
    public Page<Movie> pageQuery(MoviePageQueryDTO pageQuery) {
        PageHelper.startPage(pageQuery.getPage(),pageQuery.getPageSize());
        if (pageQuery.getName() == null) {
            pageQuery.setName("");
        }
        return movieMapper.pageQuery(pageQuery);
    }

    @Override
    public Movie getMovieById(Integer id) {
        return movieMapper.selectById(id);
    }
}
